from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class AddProductPage(BasePage):
    url = '/crm/index.php?m=product'
    product_name_locator = (By.ID, 'name')
    development_team_locator = (By.ID, 'development_team')
    suggested_price_locator = (By.ID, 'suggested_price')
    save_button_locator = (By.CSS_SELECTOR, '#form1 > table > tfoot > tr > td > input:nth-child(1)')
    save_success_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')

    # 输入产品名称
    def input_product_name(self, product_name):
        self.driver.find_element(*self.product_name_locator).send_keys(product_name)
    # 输入产品团队
    def input_development_team(self, development_team):
        self.driver.find_element(*self.development_team_locator).send_keys(development_team)
    # 点击保存按钮
    def click_save_button(self):
        self.driver.find_element(*self.save_button_locator).click()
    # 输入建议价格
    def input_suggested_price(self, suggested_price):
        self.driver.find_element(*self.suggested_price_locator).send_keys(suggested_price)
    # 返回保存成功的提示信息
    def save_success_info(self):
        return self.driver.find_element(*self.save_success_locator).text



